package org.studiox.graph.persistence.mybatis.tk.dao;

import org.springframework.stereotype.Repository;
import org.studiox.graph.persistence.mybatis.tk.base.BaseGraphDao;
import org.studiox.graph.persistence.mybatis.tk.domain.GraphEdgeDO;
import org.studiox.graph.persistence.mybatis.tk.mapper.GraphEdgeMapper;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

@Repository
public class GraphEdgeDao extends BaseGraphDao<GraphEdgeDO> {

  @Resource private GraphEdgeMapper graphEdgeMapper;

  @PostConstruct
  private void init() {
    mapper = graphEdgeMapper;
  }

  public Integer getGraphEdgeSize() {
    return graphEdgeMapper.selectCount(null);
  }

  public List<Long> getGraphEdgeIds() {
    return graphEdgeMapper.getGraphEdgeIds();
  }

  public List<Long> getGraphUniqueMinEdgeIds() {
    return graphEdgeMapper.getGraphUniqueMinEdgeIds();
  }

  public List<Long> getGraphUniqueMaxEdgeIds() {
    return graphEdgeMapper.getGraphUniqueMaxEdgeIds();
  }

  public Long getGraphEdgeContentSize(String sourceVertexUniq, String targetVertexUniq) {
    return graphEdgeMapper.getGraphEdgeContentSize(sourceVertexUniq, targetVertexUniq);
  }

  public List<String> getGraphEdgeContents(String sourceVertexUniq, String targetVertexUniq) {
    return graphEdgeMapper.getGraphEdgeContents(sourceVertexUniq, targetVertexUniq);
  }

  public List<GraphEdgeDO> getGraphEdgeDOs(GraphEdgeDO graphEdgeDO) {
    return graphEdgeMapper.select(graphEdgeDO);
  }

  public GraphEdgeDO getOneGraphEdgeDoBySourceTargetUniq(
      String sourceVertexUniq, String targetVertexUniq) {
    return graphEdgeMapper.getOneGraphEdgeDoBySourceTargetUniq(sourceVertexUniq, targetVertexUniq);
  }

  public Long getGraphEdgeId(String content, String sourceVertexUniq, String targetVertexUniq) {
    return graphEdgeMapper.getGraphEdgeId(content, sourceVertexUniq, targetVertexUniq);
  }

  public void updateGraphEdgeContentMd5(Long id) {
    graphEdgeMapper.updateGraphEdgeContentMd5(id);
  }

  public void updateAllGraphEdgeContentMd5() {
    graphEdgeMapper.updateAllGraphEdgeContentMd5();
  }

  public void updateJanusEdgeId(Long id, String janusEdgeId) {
    graphEdgeMapper.updateJanusEdgeId(id, janusEdgeId);
  }

  public void updateJanusEdgeIdAndSourceTargetVertexId(
      Long id, String janusEdgeId, Long sourceJanusVertexId, Long targetJanusVertexId) {
    graphEdgeMapper.updateJanusEdgeIdAndSourceTargetVertexId(
        id, janusEdgeId, sourceJanusVertexId, targetJanusVertexId);
  }

  public void updateNeo4jEdgeId(Long id, Long neo4jEdgeId) {
    graphEdgeMapper.updateNeo4jEdgeId(id, neo4jEdgeId);
  }

  public void updateNeo4jEdgeIdAndSourceTargetVertexId(
      Long id, Long neo4jEdgeId, Long sourceNeo4jVertexId, Long targetNeo4jVertexId) {
    graphEdgeMapper.updateNeo4jEdgeIdAndSourceTargetVertexId(
        id, neo4jEdgeId, sourceNeo4jVertexId, targetNeo4jVertexId);
  }

  public void updateNebulaEdgeId(Long id, String nebulaEdgeId) {
    graphEdgeMapper.updateNebulaEdgeId(id, nebulaEdgeId);
  }

  public void updateNebulaEdgeIdAndSourceTargetVertexId(
      Long id, String nebulaEdgeId, Long sourceNebulaVertexId, Long targetNebulaVertexId) {
    graphEdgeMapper.updateNebulaEdgeIdAndSourceTargetVertexId(
        id, nebulaEdgeId, sourceNebulaVertexId, targetNebulaVertexId);
  }

  public void updateSourceJanusVertexId(String sourceVertexUniq, Long sourceJanusVertexId) {
    graphEdgeMapper.updateSourceJanusVertexId(sourceVertexUniq, sourceJanusVertexId);
  }

  public void updateTargetJanusVertexId(String sourceVertexUniq, Long targetJanusVertexId) {
    graphEdgeMapper.updateTargetJanusVertexId(sourceVertexUniq, targetJanusVertexId);
  }

  public void updateAllSourceJanusVertexId() {
    graphEdgeMapper.updateAllSourceJanusVertexId();
  }

  public void updateAllTargetJanusVertexId() {
    graphEdgeMapper.updateAllTargetJanusVertexId();
  }

  public void updateAllSourceTargetJanusVertexId() {
    graphEdgeMapper.updateAllSourceTargetJanusVertexId();
  }

  public void updateSourceNeo4jVertexId(String sourceVertexUniq, Long sourceNeo4jVertexId) {
    graphEdgeMapper.updateSourceNeo4jVertexId(sourceVertexUniq, sourceNeo4jVertexId);
  }

  public void updateTargetNeo4jVertexId(String sourceVertexUniq, Long targetNeo4jVertexId) {
    graphEdgeMapper.updateTargetNeo4jVertexId(sourceVertexUniq, targetNeo4jVertexId);
  }

  public void updateAllSourceNeo4jVertexId() {
    graphEdgeMapper.updateAllSourceNeo4jVertexId();
  }

  public void updateAllTargetNeo4jVertexId() {
    graphEdgeMapper.updateAllTargetNeo4jVertexId();
  }

  public void updateAllSourceTargetNeo4jVertexId() {
    graphEdgeMapper.updateAllSourceTargetNeo4jVertexId();
  }

  public void updateSourceNebulaVertexId(String sourceVertexUniq, Long sourceNebulaVertexId) {
    graphEdgeMapper.updateSourceNebulaVertexId(sourceVertexUniq, sourceNebulaVertexId);
  }

  public void updateTargetNebulaVertexId(String sourceVertexUniq, Long targetNebulaVertexId) {
    graphEdgeMapper.updateTargetNebulaVertexId(sourceVertexUniq, targetNebulaVertexId);
  }

  public void updateAllSourceNebulaVertexId() {
    graphEdgeMapper.updateAllSourceNebulaVertexId();
  }

  public void updateAllTargetNebulaVertexId() {
    graphEdgeMapper.updateAllTargetNebulaVertexId();
  }

  public void updateAllSourceTargetNebulaVertexId() {
    graphEdgeMapper.updateAllSourceTargetNebulaVertexId();
  }

  public void deleteGraphEdgeByDbId(Long dbId) {
    graphEdgeMapper.deleteByPrimaryKey(dbId);
  }
}
